package com.smartTLC.dao;
import com.smartTLC.domain.entity.OtherUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Repository;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDao {
    /*@Autowired
    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
    private  final static String MATCH_COUNT_SQL = " SELECT count(*) FROM t_teacher  " +
            " WHERE user_name =? and password=? ";


    public int getMatchCount(String userName, String password) {

        return jdbcTemplate.queryForObject(MATCH_COUNT_SQL, new Object[]{userName, password}, Integer.class);
    }
    public OtherUser findUserByUserName(final String userName) {
        String sqlStr = "select user_id,name,user_name,password,phonenumber" +
                " from t_teacher where user_name=?";
        OtherUser user = new OtherUser();
        jdbcTemplate.query(sqlStr, new Object[] { userName },
                new RowCallbackHandler() {
                    public void processRow(ResultSet rs) throws SQLException {
                        user.setId(rs.getString("id"));
                        user.setName(rs.getString("name"));
                        user.setUsername(rs.getString("username"));
                        user.setUserpwd(rs.getString("userpwd"));
                        user.setPhonenum(rs.getString("phonenum"));
                    }
                });
        return user;
    }*/

}
